# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Matt Monaco <cx monaco matt>

pkgname=lmdb
pkgver=0.9.29
pkgrel=1
pkgdesc="Symas Lightning Memory-Mapped Database"
arch=('x86_64')
url="https://symas.com/mdb"
license=('custom:OpenLDAP')
depends=('glibc')
options=('!emptydirs')
source=("https://git.openldap.org/openldap/openldap/-/archive/LMDB_$pkgver/openldap-LMDB_$pkgver.tar.gz" lmdb.pc)
sha512sums=('b41ba5b139375d23617a79f4d322399df55745c5a4a63159ddbe0f1ded4707f0eb7f71acf3d1a4928f8fcab30a7b5db17e3e165441a61ec1dbd29f8d9efa65d1'
            '0349d4b08a1f93fe338d8f8e3e5a83e24211a46f999fe529bc1ac49c8c4975559d95a548c203d9427e3f82d62e934ba3cd1be6f734f9b9405b2a26477be4ed33')

prepare() {
  sed -e "s|@PKGVER@|$pkgver|" -i lmdb.pc
}

build() {
  cd "$srcdir"/openldap-LMDB_$pkgver/libraries/liblmdb
  make prefix=/usr
}

check() {
  cd "$srcdir"/openldap-LMDB_$pkgver/libraries/liblmdb
  make test
}

package() {
  cd "$srcdir"/openldap-LMDB_$pkgver/libraries/liblmdb
  install -dm755 "$pkgdir"/usr/{bin,lib,include,man/man1,share}
  make DESTDIR="$pkgdir" prefix=/usr install

  mv "$pkgdir"/usr/man "$pkgdir"/usr/share/man

  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
  install -Dm644 "$srcdir"/lmdb.pc "$pkgdir"/usr/lib/pkgconfig/lmdb.pc
}
